// JavaScript Document
jQuery(document).ready(function($) {
    console.log(111111)
    $(".m3Editor p img").css("display","inline");
if(typeof(Worker) == "undefined"){window.location = "noHtml5.html";}
animateImg();
function animateImg(){
  new WOW().init();
}

//µ¼º½
$(".megamenu-fw").hover(function(){
	var LeftVal = ($(window).width()-$(".dropdown-menu").width())/2;
	    cssLeft = $(this).offset().left-LeftVal+$(this).width()/2+6;
	    $(".dropdown_icon").css("left",cssLeft);
	});

    //Ìá½»ÁôÑÔ
$(".m2nlx_submit").click(function () {

    var fname = $("#fname").val();
    var email = $("#email").val();
 var Phone = $("#tel").val();
    var lname = $("#lname").val();
    var company = $("#company").val();
    var notes = $("#notes").val();
    var country = $("#country").val();

    var name = fname + " " + lname;

    if (fname == "") {
        alert("Please fill in your name"); return;
    }
    if (lname == "") {
        alert("Please fill in your name"); return;
    }
    if (Phone== "") {
        alert("Please fill in your phone"); return;
    }
    if (notes.length > 100) {
        alert("Please control the number of words."); return;
    }
    var re = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;

    if (re.test(email) == false) { alert("Please fill in the correct email address£¡"); return; }



    var category = "2";

    $.get("/ajax/message.ashx", {
        name: name,
        company: company,
        country: country,
        email: email,
 phone: Phone,
        category: category,
        notes: notes

    }, function (data, textStatus) {
        if (textStatus == "success") {

            //dai alert("Submit successfully!");
			window.location.href="https://www.inhandnetworks.com/thankyou.html";
          //dai  location.reload();
        }
    });


});
//Ê×Ò³Banner
var hmFocus161009 = new Swiper('.hmBan', {
	pagination: '.hmBan .swiper-pagination',
	nextButton: '.hmBanBtnR',
	prevButton: '.hmBanBtnL',
	paginationClickable: true,
	onlyExternal : false,
	autoplay: 6000,
    effect: 'fade',
	autoplayDisableOnInteraction : false,
	speed: 1000,
	spaceBetween: 0,
	loop: true,
	onInit: function(swiper){ 
		swiperAnimateCache(swiper); 
		swiperAnimate(swiper); 
	  }, 
    onSlideChangeEnd: function(swiper){ 
		swiperAnimate(swiper);
	}
});

//²úÆ·
var swiper = new Swiper('.hmProSwiper', {
	nextButton: '.hmProBtnR',
	prevButton: '.hmProBtnL',
	slidesPerView: 4,
	paginationClickable: true,
	spaceBetween: 0,
	loop: true,
	breakpoints: { 
    767: {
      slidesPerView: 1,
      spaceBetweenSlides: 10
    },
	993: {
      slidesPerView: 2,
      spaceBetweenSlides: 10
    },
    1200: { 
      slidesPerView: 3,
      spaceBetweenSlides: 20
    },
  }
});
    //ËÑË÷
    $('.navSubmitBtn').click(function () {

        var title = $(".navSerBox").val();
        if (title == "") { alert("Please enter a keyword"); return; }
    window.location.href = "/search.aspx?title=" + title;

});

    $('.navSerBox').keydown(function (e) {
    if (e.keyCode == 13) {
        var title = $(".navSerBox").val();
        if (title == "") { alert("Please enter a keyword"); return; }
        window.location.href = "/search.aspx?title=" + title;
    }
    });
    //ËÑË÷
    $('.mserBtnSubmit').click(function () {

        var title = $(".m_navSerBoxSy").val();
        if (title == "") { alert("Please enter a keyword"); return; }
        window.location.href = "/search.aspx?title=" + title;

    });

    $('.m_navSerBoxSy').keydown(function (e) {
        if (e.keyCode == 13) {
            var title = $(".m_navSerBoxSy").val();
            if (title == "") { alert("Please enter a keyword"); return; }
            window.location.href = "/search.aspx?title=" + title;
        }
    });
    //ËÑË÷
    $('.hmBomSerBtn').click(function () {

        var title = $("#search").val();
        if (title == "") { alert("Please enter a keyword"); return; }
        window.location.href = "/search.aspx?title=" + title;

    });

    $('#search').keydown(function (e) {
        if (e.keyCode == 13) {
            var title = $("#search").val();
            if (title == "") { alert("Please enter a keyword"); return; }
            window.location.href = "/search.aspx?title=" + title;
        }
    });
    //ËÑË÷
    $('.m2dwSubmit').click(function () {

        var title = $(".m2serInt").val();
        if (title == "") { alert("Please enter a keyword"); return; }
        window.location.href = "/downlist.aspx?Keywords=" + title;

    });

    $('.m2serInt').keydown(function (e) {
        if (e.keyCode == 13) {
            var title = $(".m2serInt").val();
            if (title == "") { alert("Please enter a keyword"); return; }
            window.location.href = "/downlist.aspx?Keywords=" + title;
        }
    });
//ÓÑÁ¬
var swiper = new Swiper('.hmBomSwiper', {
	nextButton: '.hmLogoBtnR',
	prevButton: '.hmLogoBtnL',
	slidesPerView: 6,
	paginationClickable: true,
	spaceBetween: 14,
	loop: true,
	breakpoints: { 
    767: {
      slidesPerView: 2,
      spaceBetweenSlides: 10
    },
	993: {
      slidesPerView: 4,
      spaceBetweenSlides: 10
    },
    1200: { 
      slidesPerView: 5,
      spaceBetweenSlides: 20
    },
  }
});

//ËÑË÷
var flag = true;
$(".navSerBtn").click(function(){
	$(".navSer").addClass("navCutSer");
	$(".navSubmitBtn").fadeIn(100);
	setTimeout(function(){$(".navSerBox").focus();},1000);
	});
$(".navSer").hover(function(){flag = true;},function(){flag = false;});
$(document).click(function(){
	if(!flag){$(".navSer").removeClass("navCutSer");$(".navSubmitBtn").fadeOut(100);}
})

$(".mserBtn").click(function(){
	$(".mserIntBox").fadeToggle(300);
	});

//imgTextBox
$(".imgTextBox").each(function(i) {
	if($(".imgTextPbox").eq(i).height()<$(".imgTextImgBox").eq(i).height()){
		$(".imgTextBox").eq(i).height($(".imgTextImgBox").eq(i).height());
		$(".imgTextPbox").eq(i).height($(".imgTextImgBox").eq(i).height());
		$(".imgTxtTable").eq(i).height($(".imgTextImgBox").eq(i).height());
		}
});

//²úÆ·ÏêÇéÇÐ»»
$(".m3changeBtn span").click(function(){
	$(".m3changeBtn span .m3menu_a").removeClass("on");
	$(this).find(".m3menu_a").addClass("on");
	$(".m3proEditor").eq($(this).index()).show().addClass('fadeInUp animated').siblings(".m3proEditor").hide();
});

//·þÎñÓëÖ§³Ö
$(".m2wdList dt").click(function(){
	if($(this).next("dd").css("display")=="none"){
		$(".m2wdList dt").removeClass("on");
		$(".m2wdList dd").slideUp(300);
		$(this).addClass("on");
		$(this).next("dd").slideDown(300);
	}else{
		$(this).removeClass("on");
		$(this).next("dd").slideUp(300);
		}
});

//Àú³Ì
$(".m2usYearBoxText:gt(0)").hide();
var m2usSwiper = new Swiper('.m2usSwiper', {
	nextButton: '.m2usBtnR',
	prevButton: '.m2usBtnL',
	slidesPerView: 6,
	paginationClickable: true,
	spaceBetween:0,
	slidesPerGroup : 6,
	onSlideChangeStart: function(){
	  $(".m2usSwiper .swiper-slide").removeClass("swiper-slide-on");
	  $(".m2usYearBoxText").eq(m2usSwiper.activeIndex).show().addClass('fadeInUp animated').siblings(".m2usYearBoxText").hide();
    },
	breakpoints: {
    767: {
      slidesPerView: 2,
	  slidesPerGroup : 2,
    }
	}
});
$(".m2usSwiper .swiper-slide").click(function(){
	$(".m2usSwiper .swiper-slide").removeClass("swiper-slide-active swiper-slide-on");
	$(".m2usSwiper .swiper-slide").eq($(this).index()).addClass("swiper-slide-on");
	$(".m2usYearBoxText").hide();
	$(".m2usYearBoxText").eq($(this).index()).show();
	});


//×ÊÖÊ
var m2usSwiper2 = new Swiper('.m2usSwiper2 .swiper-container', {
	nextButton: '.m2usBR',
	prevButton: '.m2usBL',
	slidesPerView:4,
	paginationClickable: true,
	spaceBetween: 68,
	loop: true,
	breakpoints: {
    767: {
      slidesPerView: 1,
    },
	1100: {
      slidesPerView: 3,
	  spaceBetween:35,
    }
	}
});

//Ö÷Òª¿Í»§
var hmp7LgList = new Swiper('.m2usList', {
	pagination: '.m2usList .swiper-pagination',
	slidesPerView: 6,
	slidesPerColumn: 2,
	paginationClickable: true,
	spaceBetween: 12,
	breakpoints: {
    767: {
      slidesPerView: 2,
    },
	1000: {
      slidesPerView: 4,
    }
  }
});

//ÕÐÆ¸
$(".m2zpBox dt").click(function(){
	if($(this).next("dd").css("display")=="none"){
		$(".m2zpBox dt").removeClass("on");
		$(".m2zpBox dd").slideUp(300);
		$(this).addClass("on");
		$(this).next("dd").slideDown(300);
	}else{
		$(this).removeClass("on");
		$(this).next("dd").slideUp(300);
		}
});

//ÏÂÔØ
$(".m2dwOption li").click(function(){
	$(".m2dwInt2").val($(this).text());
	$(".m2dwOption").slideUp(200);
	});
$(".m2dwInt2").focus(function(){
	$(".m2dwOption").slideDown(200);
	});
$(".m2dwSelBox").hover(function(){
	return false;
	},function(){
		$(".m2dwOption").slideUp(200);
		$(".m2dwInt2").blur();
		});


});



//·µ»Ø¶¥²¿
$("#Top").click(function(){
	$('html,body').animate({scrollTop:"0px"},800);
})
$(window).scroll(function(){
	if($(window).scrollTop()>100){
		$("#Top").slideDown();
	}else{
		$("#Top").slideUp();
	}
})

//ÆÁ±ÎÒ³Ãæ´íÎó
jQuery(window).error(function(){
  return true;
});
jQuery("img").error(function(){
  $(this).hide();
});

$("#Top").click(function(){
	$('html,body').animate({scrollTop:"0px"},800);
})
$(window).scroll(function(){
	if($(window).scrollTop()>100){
		$("#Top").slideDown();
	}else{
		$("#Top").slideUp();
	}
})